package com.vista.questionnaire.exception;

import java.util.HashMap;
import java.util.Map;

public class BizException extends RuntimeException {

    private int code;

    public BizException(ErrorDescriptor descriptor) {
        super(descriptor.toString());
        this.code = descriptor.getCode();
    }

    public BizException(int code, String message) {
        super(message);
        this.code = code;
    }

    public Map<String, Object> getErrorDescriptor() {
        Map<String, Object> map = new HashMap<>();
        map.put("code", this.code);
        map.put("description", this.getMessage());
        return map;
    }

}
